<?php
/**
 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
 */
class LanguageSetter extends CApplicationComponent
{

	const LANG_ENGLISH = "en";
	const LANG_VIETNAMESE = "vi";

	private $lang = '';

	public function init()
	{
		$this->lang = LanguageSetter::LANG_ENGLISH;
		if (!is_null(Yii::app()->session["boxanh_lang"]))
		{
			$this->lang = Yii::app()->session["boxanh_lang"];
		}
		else
		{
			if(isset(Yii::app()->request->cookies['boxanh_lang']))
			{
				$this->lang = Yii::app()->request->cookies['boxanh_lang']->value;
			}
		}

		Yii::app()->setLanguage($this->lang);	
	}

    public function lang()
    {
    	return $this->lang;
    }
}